use utf8;
package GlavFinans::Schema::Result::Role;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME

GlavFinans::Schema::Result::Role

=cut

use strict;
use warnings;

use base 'DBIx::Class::Core';

=head1 TABLE: C<role>

=cut

__PACKAGE__->table("role");

=head1 ACCESSORS

=head2 id

  data_type: 'integer'
  is_auto_increment: 1
  is_nullable: 0
  sequence: 'role_id_seq'

=head2 guid

  data_type: 'uuid'
  default_value: uuid_generate_v4()
  is_nullable: 0
  size: 16

=head2 relname

  data_type: 'text'
  is_nullable: 0
  original: {data_type => "varchar"}

=head2 name

  data_type: 'text'
  is_nullable: 0
  original: {data_type => "varchar"}

=head2 created

  data_type: 'timestamp'
  default_value: current_timestamp
  is_nullable: 0
  original: {default_value => \"now()"}

=head2 updated

  data_type: 'timestamp'
  default_value: current_timestamp
  is_nullable: 0
  original: {default_value => \"now()"}

=head2 pid

  data_type: 'integer'
  is_foreign_key: 1
  is_nullable: 1

=head2 trail

  data_type: 'ltree'
  is_nullable: 1

=head2 level

  data_type: 'integer'
  is_nullable: 0

=cut

__PACKAGE__->add_columns(
  "id",
  {
    data_type         => "integer",
    is_auto_increment => 1,
    is_nullable       => 0,
    sequence          => "role_id_seq",
  },
  "guid",
  {
    data_type => "uuid",
    default_value => \"uuid_generate_v4()",
    is_nullable => 0,
    size => 16,
  },
  "relname",
  {
    data_type   => "text",
    is_nullable => 0,
    original    => { data_type => "varchar" },
  },
  "name",
  {
    data_type   => "text",
    is_nullable => 0,
    original    => { data_type => "varchar" },
  },
  "created",
  {
    data_type     => "timestamp",
    default_value => \"current_timestamp",
    is_nullable   => 0,
    original      => { default_value => \"now()" },
  },
  "updated",
  {
    data_type     => "timestamp",
    default_value => \"current_timestamp",
    is_nullable   => 0,
    original      => { default_value => \"now()" },
  },
  "pid",
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
  "trail",
  { data_type => "ltree", is_nullable => 1 },
  "level",
  { data_type => "integer", is_nullable => 0 },
);

=head1 PRIMARY KEY

=over 4

=item * L</id>

=back

=cut

__PACKAGE__->set_primary_key("id");

=head1 UNIQUE CONSTRAINTS

=head2 C<role_name_uniq_idx>

=over 4

=item * L</name>

=back

=cut

__PACKAGE__->add_unique_constraint("role_name_uniq_idx", ["name"]);

=head1 RELATIONS

=head2 group_roles

Type: has_many

Related object: L<GlavFinans::Schema::Result::GroupRole>

=cut

__PACKAGE__->has_many(
  "group_roles",
  "GlavFinans::Schema::Result::GroupRole",
  { "foreign.dst" => "self.id" },
  { cascade_copy => 0, cascade_delete => 0 },
);

=head2 pid

Type: belongs_to

Related object: L<GlavFinans::Schema::Result::Role>

=cut

__PACKAGE__->belongs_to(
  "pid",
  "GlavFinans::Schema::Result::Role",
  { id => "pid" },
  {
    is_deferrable => 1,
    join_type     => "LEFT",
    on_delete     => "CASCADE",
    on_update     => "CASCADE",
  },
);

=head2 roles

Type: has_many

Related object: L<GlavFinans::Schema::Result::Role>

=cut

__PACKAGE__->has_many(
  "roles",
  "GlavFinans::Schema::Result::Role",
  { "foreign.pid" => "self.id" },
  { cascade_copy => 0, cascade_delete => 0 },
);

=head2 users

Type: has_many

Related object: L<GlavFinans::Schema::Result::User>

=cut

__PACKAGE__->has_many(
  "users",
  "GlavFinans::Schema::Result::User",
  { "foreign.role" => "self.name" },
  { cascade_copy => 0, cascade_delete => 0 },
);


# Created by DBIx::Class::Schema::Loader v0.07025 @ 2012-07-31 13:04:13
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1C5fux9+xIv1hdzNDMsN2g


# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
